package practice1_100;

import java.util.Comparator;
import java.util.PriorityQueue;

public class Practice226 {
    public TreeNode invertTree(TreeNode root) {
        TreeNode head=root;
        dp(head);
        return  root;
    }

    public void dp(TreeNode root){
        if(root!=null&&(root.left!=null||root.right!=null)){
            TreeNode temp= root.left;
            root.left=root.right;
            root.right=temp;
        }else return;

        dp(root.left);
        dp(root.right);

    }

    public static void main(String[] args) {
        PriorityQueue<Integer> priorityQueue=new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });
//        priorityQueue.pe
        priorityQueue.remove(2);
//        priorityQueue.p
        TreeNode root=new TreeNode(1);
        root.left=new TreeNode(2);
        root.right=new TreeNode(3);
        root.left.left=new TreeNode(4);
        TreeNode a=new Practice226().invertTree(root);
        System.out.println(a);
    }
}
